import java.util.Scanner;

// 计算字符串的编程距离
public class Main2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s1 = scanner.next();
        String s2 = scanner.next();
        char[] str1 = s1.toCharArray();
        char[] str2 = s2.toCharArray();
        int length1 = str1.length;
        int length2 = str2.length;

        int[][] dp = new int[length1+1][length2+1];
        for (int i = 1; i <= length1; i++) {
            dp[i][0] = i;
        }
        for (int i = 1; i <= length2; i++) {
            dp[0][i] = i;
        }
        for (int i = 1; i <= length1; i++) {
            for (int j = 1; j <= length2; j++) {
                dp[i][j] = Math.min(dp[i-1][j], dp[i][j - 1]) + 1;
                dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - 1] + (str1[i - 1] == str2[j - 1] ? 0 : 1));
            }
        }
        System.out.println(dp[length1][length2]);
    }

}